//tạo 1 file rôi ghi thêm nội dung vào file đấy
 
package my.library;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author saltcoffee
 */
public class WriteFile {
    public static void main(String[] args) {
        try {
            File file1=new File("test1.txt");
            file1.createNewFile();
            FileWriter fw=new FileWriter(file1);
            BufferedWriter bw=new BufferedWriter(fw);
            String s="Nguyen Xuan Minh";
            bw.write(s);
            bw.close();
            fw.close();
        } catch (IOException ex) {
            Logger.getLogger(WriteFile.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
